package com.gzq.common;

import android.os.Parcel;
import android.os.Parcelable;

import com.gzq.common_core.session.ISessionUser;

public class UserInfo implements ISessionUser, Parcelable {
    private String name;
    private int age;
    private double weight;
    private float height;
    private boolean isAdult;
    private Education education;

    public UserInfo() {
    }

    public UserInfo(String name, int age, double weight, float height, boolean isAdult, Education education) {
        this.name = name;
        this.age = age;
        this.weight = weight;
        this.height = height;
        this.isAdult = isAdult;
        this.education = education;
    }

    protected UserInfo(Parcel in) {
        name = in.readString();
        age = in.readInt();
        weight = in.readDouble();
        height = in.readFloat();
        isAdult = in.readByte() != 0;
        education = in.readParcelable(Education.class.getClassLoader());
    }

    public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
        @Override
        public UserInfo createFromParcel(Parcel in) {
            return new UserInfo(in);
        }

        @Override
        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeInt(age);
        dest.writeDouble(weight);
        dest.writeFloat(height);
        dest.writeByte((byte) (isAdult ? 1 : 0));
        dest.writeParcelable(education, flags);
    }

    public static class Education implements Parcelable {
        private String university;
        private String grade;
        private String teachName;

        public Education() {
        }

        public Education(String university, String grade, String teachName) {
            this.university = university;
            this.grade = grade;
            this.teachName = teachName;
        }

        protected Education(Parcel in) {
            university = in.readString();
            grade = in.readString();
            teachName = in.readString();
        }

        public static final Creator<Education> CREATOR = new Creator<Education>() {
            @Override
            public Education createFromParcel(Parcel in) {
                return new Education(in);
            }

            @Override
            public Education[] newArray(int size) {
                return new Education[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(university);
            dest.writeString(grade);
            dest.writeString(teachName);
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }

    public boolean isAdult() {
        return isAdult;
    }

    public void setAdult(boolean adult) {
        isAdult = adult;
    }

    public Education getEducation() {
        return education;
    }

    public void setEducation(Education education) {
        this.education = education;
    }
}
